package com;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class JDBC_06_TestDBUtil {

	public static void main(String[] args) {
		Connection connection = null;
		PreparedStatement preparedStatement = null;
		ResultSet resultSet = null;
		try {
			connection = DBUtil.getConnection();
			preparedStatement = connection.prepareStatement("select * from t_user");
			resultSet = preparedStatement.executeQuery();
			while (resultSet.next()) {
				System.out.print(resultSet.getInt("id") + " ");
				System.out.print(resultSet.getString("username") + " ");
				System.out.print(resultSet.getString("password") + " ");
				System.out.println(resultSet.getString("nickname") + " ");
			}
		} catch (ClassNotFoundException | SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				DBUtil.close(resultSet);
				DBUtil.close(preparedStatement);
				DBUtil.close(connection);
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
	}

}
